﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace PcCtrlUI
{
	/// <summary>
	/// Interaction logic for RelayCtrl.xaml
	/// </summary>
	public partial class RelayCtrl : UserControl
	{
		public RelayCtrl()
		{
			this.InitializeComponent();
		}

        public void setValue(int r, bool v)
        {
            switch (r)
            {
                case 0:
                    relay0.IsChecked = v;
                    break;
                case 1:
                    relay1.IsChecked = v;
                    break;
                case 2:
                    relay2.IsChecked = v;
                    break;
                case 3:
                    relay3.IsChecked = v;
                    break;
                case 4:
                    relay4.IsChecked = v;
                    break;
                case 5:
                    relay5.IsChecked = v;
                    break;
                case 6:
                    relay6.IsChecked = v;
                    break;
                case 7:
                    relay7.IsChecked = v;
                    break;
            };
        }

		private void relay0_Click(object sender, System.Windows.RoutedEventArgs e)
		{
			App app = (App)App.Current;
            app.getMcCOMChannel().setRelay(0,relay0.IsChecked.Value);
		}

		private void relay1_Click(object sender, System.Windows.RoutedEventArgs e)
		{
            App app = (App)App.Current;
            app.getMcCOMChannel().setRelay(1, relay1.IsChecked.Value);
		}

		private void relay2_Click(object sender, System.Windows.RoutedEventArgs e)
		{
            App app = (App)App.Current;
            app.getMcCOMChannel().setRelay(2, relay2.IsChecked.Value);
		}

		private void relay3_Click(object sender, System.Windows.RoutedEventArgs e)
		{
            App app = (App)App.Current;
            app.getMcCOMChannel().setRelay(3, relay3.IsChecked.Value);
		}

		private void relay4_Click(object sender, System.Windows.RoutedEventArgs e)
		{
            App app = (App)App.Current;
            app.getMcCOMChannel().setRelay(4, relay4.IsChecked.Value);
		}

		private void relay5_Click(object sender, System.Windows.RoutedEventArgs e)
		{
            App app = (App)App.Current;
            app.getMcCOMChannel().setRelay(5, relay5.IsChecked.Value);
		}

		private void relay6_Click(object sender, System.Windows.RoutedEventArgs e)
		{
            App app = (App)App.Current;
            app.getMcCOMChannel().setRelay(6, relay6.IsChecked.Value);
		}

		private void relay7_Click(object sender, System.Windows.RoutedEventArgs e)
		{
            App app = (App)App.Current;
            app.getMcCOMChannel().setRelay(7, relay7.IsChecked.Value);
		}
	}
}